Contents

1 Introduction

This vignette gives an overview of spatial data visualization with the SingleCellMapper package. This document also introduces the ImageList class, which inherits from the SimpleList class.

Explain: images, masks, sce

2 Quick start

Here, we will highlight the most simple use of the package

Load the libraries

Load the example data: SingleCellExperiment object

load("../data/pancreasSCE.RData")
pancreasSCE
## class: SingleCellExperiment 
## dim: 5 282 
## metadata(0):
## assays(2): counts exprs
## rownames(5): H3 SMA INS CD38 CD44
## rowData names(4): frame MetalTag Target clean_Target
## colnames(282): A02_imc.7 A02_imc.10 ... F01_imc.362 F01_imc.367
## colData names(10): ImageNb CellNb ... MaskName CellType
## reducedDimNames(0):
## spikeNames(0):
## altExpNames(0):

Load the example data: List of images

load("../data/pancreasImages.RData")
pancreasImages
## ImageList containing 3 image(s)
## names(3): A02_imc D01_imc F01_imc 
## Each image contains 5 channel(s)
## channelNames(5): H3 SMA INS CD38 CD44

Load the example data: List of masks

load("../data/pancreasMasks.RData")
pancreasMasks
## ImageList containing 3 image(s)
## names(3): A02_mask D01_mask F01_mask 
## Each image contains 1 channel(s)

Getting channel names

channelNames(pancreasImages)
## [1] "H3"   "SMA"  "INS"  "CD38" "CD44"

2.1 Quick plotting of pixel-level information

Illustration of the plotPixel function
Quick start: plot pixel-level information

Figure 1: Quick start: plot pixel-level information

Displaying the cell masks. Here, ‘img_id’ is used to match images and masks. The ‘ImageNb’ column is present in both ‘mcols(pancreasImages)’ and ‘mcols(pancreasMasks)’
Quick start: plot cell masks

Figure 2: Quick start: plot cell masks

Plotting specific channels
Quick start: plot specific channels

Figure 3: Quick start: plot specific channels

2.2 Quick plotting of cell-level information

Illustration of the plotCells function
Quick start: plot cell-level information

Figure 4: Quick start: plot cell-level information

Colouring cells. ‘colour_by’ should be a column in ‘colData(pancreasSCE)’ ‘expr_values’ should be an assay in ‘assays(pancreasSCE)’
Quick start: colour by cell type

Figure 5: Quick start: colour by cell type

Displaying cell outlines ‘outline_by’ should be a column in colData(pancreasSCE)
Quick start: outline by cell type

Figure 6: Quick start: outline by cell type

3 Reading in data

3.1 Data format

Images should be stacks, all stacks should have the same number of channels Masks should be single-channel images Object should be a SingleCellExperiment

3.2 Load images

Introduction to the LoadImage function

3.3 Add metadata

mcols(pancreasImages)
## DataFrame with 3 rows and 1 column
##           ImageNb
##         <integer>
## A02_imc         1
## D01_imc         2
## F01_imc         3
mcols(pancreasMasks)
## DataFrame with 3 rows and 1 column
##            ImageNb
##          <integer>
## A02_mask         1
## D01_mask         2
## F01_mask         3
colData(pancreasSCE)$ImageNb
##   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##  [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##  [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [112] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [149] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
## [186] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [223] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [260] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

4 The ImageList object

4.1 Accessors

4.2 Coercion

4.3 Subsetting

4.4 Looping

5 Plotting pixel-level information

5.1 Scaling

5.2 Normalization

6 Plotting Cell-level information

6.1 Normalization

7 Saving images

8 Acknowledgements

9 Contributions

Nicolas created SingleCellMapper - Nicolas and Nils implemented the package …

10 References

Session info

## R version 3.6.1 (2019-07-05)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.6 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/libblas/libblas.so.3.6.0
## LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] SingleCellMapper_0.1.5      SingleCellExperiment_1.8.0 
##  [3] SummarizedExperiment_1.16.1 DelayedArray_0.12.2        
##  [5] BiocParallel_1.20.1         matrixStats_0.55.0         
##  [7] Biobase_2.46.0              GenomicRanges_1.38.0       
##  [9] GenomeInfoDb_1.22.0         IRanges_2.20.2             
## [11] S4Vectors_0.24.3            BiocGenerics_0.32.0        
## [13] EBImage_4.28.1              BiocStyle_2.14.4           
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.3             locfit_1.5-9.1         lattice_0.20-40       
##  [4] fftwtools_0.9-8        png_0.1-7              assertthat_0.2.1      
##  [7] digest_0.6.24          R6_2.4.1               tiff_0.1-5            
## [10] evaluate_0.14          ggplot2_3.2.1          highr_0.8             
## [13] pillar_1.4.3           zlibbioc_1.32.0        rlang_0.4.4           
## [16] lazyeval_0.2.2         raster_3.0-12          Matrix_1.2-18         
## [19] rmarkdown_2.1          stringr_1.4.0          htmlwidgets_1.5.1     
## [22] RCurl_1.98-1.1         munsell_0.5.0          compiler_3.6.1        
## [25] xfun_0.12              pkgconfig_2.0.3        htmltools_0.4.0       
## [28] tidyselect_1.0.0       tibble_2.1.3           gridExtra_2.3         
## [31] GenomeInfoDbData_1.2.2 bookdown_0.17          codetools_0.2-15      
## [34] viridisLite_0.3.0      crayon_1.3.4           dplyr_0.8.4           
## [37] bitops_1.0-6           grid_3.6.1             gtable_0.3.0          
## [40] lifecycle_0.1.0        magrittr_1.5           scales_1.1.0          
## [43] stringi_1.4.6          XVector_0.26.0         viridis_0.5.1         
## [46] sp_1.3-2               RColorBrewer_1.1-2     tools_3.6.1           
## [49] glue_1.3.1             purrr_0.3.3            jpeg_0.1-8.1          
## [52] abind_1.4-5            yaml_2.2.0             colorspace_1.4-1      
## [55] BiocManager_1.30.10    knitr_1.28

11 Getting started

To enable the Bioconductor style in your R Markdown vignette you need to include the following in the DESCRIPTION file:

VignetteBuilder: knitr
Suggests: BiocStyle, knitr, rmarkdown

12 Style macros

BiocStyle introduces the following macros for referring to R packages:

13 Figures

Assign captions to figures in the code chunk option fig.cap to automatically number them, and to be able to reference them, see Figure 7. The figure label is generated from the code chunk label by prefixing it with fig:.

Regular figure. The first sentence of the figure caption is automatically emphasized to serve as figure title.

Figure 7: Regular figure
The first sentence of the figure caption is automatically emphasized to serve as figure title.

Small and wide figures can be specified by fig.small and fig.wide code chunk options.

Small figure. A plot produced by a code chunk with option `fig.small = TRUE`.

Figure 8: Small figure
A plot produced by a code chunk with option fig.small = TRUE.

Wide figure. A plot produced by a code chunk with option `fig.wide = TRUE`.

Figure 9: Wide figure
A plot produced by a code chunk with option fig.wide = TRUE.

14 Equations

To number and reference equations, put them in equation environments and assign labels to them, see Equation (1).

\[\begin{equation} f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k} \tag{1} \end{equation}\]

15 Tables

Like figures, tables with captions will also be numbered and can be referenced, see Table 1.

Table 1: A simple table
With caption.
Fruit Price
bananas 1.2
apples 1.0
oranges 2.5

16 Cross-references

Apart from referencing figures (Section 13), tables (Section 15), and equations (Section 14), you can also use the same syntax to refer to sections by their default labels generated by pandoc.

17 Side notes

Footnotes are displayed as side notes on the right margin1 this is a side note entered as a footnote, which has the advantage that they appear close to the place where they are defined.